package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController extends BaseController {


    @Autowired
    private NursingProjectService NursingProjectService;

    @GetMapping
    @ApiOperation(value = "分页查询护理项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理项目名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")

    })
    public ResponseResult selectByPage(Integer pageNum, Integer pageSize, String name, Integer status) {

        PageResponse<NursingProjectVo> pageInfo = NursingProjectService.selectByPage(pageNum, pageSize, name, status);

        return success(pageInfo);
    }


    @PostMapping
    @ApiOperation(value = "添加护理项目")
    public ResponseResult addNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {

                NursingProjectService.addNursingProject(nursingProjectDto);

                return success();
            }


    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目")
    public ResponseResult<NursingProjectVo> selectById(@PathVariable Long id) {

        NursingProjectVo nursingProjectVo = NursingProjectService.selectById(id);

        return success(nursingProjectVo);
     }

     @PutMapping
     @ApiOperation(value = "修改护理项目")
     public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {

         NursingProjectService.updateNursingProject(nursingProjectDto);

         return success();
     }

     @PutMapping("/{id}/status/{status}")
     @ApiOperation(value = "启用、禁用护理项目")
     public ResponseResult updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {

         NursingProjectService.updatestatus(id, status);

         return success();
     }

     @DeleteMapping("/{id}")
     @ApiOperation(value = "删除护理项目")
     public ResponseResult deleteNursingProject(@PathVariable Long id) {

         NursingProjectService.deleteNursingProject(id);

         return success();
     }


     @GetMapping("/all")
     @ApiOperation(value = "查询所有护理项目")
     public ResponseResult<List<NursingProjectVo>> getAllNursingProjects() {
         List<NursingProjectVo> NursingProjects = NursingProjectService.getAllNursingProjects();
         return success(NursingProjects);
     }






}
